home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 106 / pascal / st_time.inc < prev    next >
Encoding:
Text File  |  1987-02-20  |  1.0 KB  |  34 lines

  1. FUNCTION Time : REAL;
  2.  
  3. { Function to demonstrate method of grabbing the 200 hz timer in
  4.   system varialbes area ($4BA)
  5.   Sept. 25, 1986 by M. Curry }
  6. { Note from Jinfu Chen:
  7.   You can use the built-in function CLOCK in Personal Pascal for less timing
  8.   sensitive application as CLOCK only gives 2 second resolution }
  9.  
  10. TYPE
  11.   Long_Pointer = ^Long_Integer ;
  12.  
  13. VAR
  14.   SSP : Long_Integer ;
  15.   hz_200 : RECORD
  16.      CASE BOOLEAN OF
  17.        TRUE  : ( l : Long_Integer ) ;
  18.        FALSE : ( p : Long_Pointer ) ;
  19.      END ;
  20.  
  21. FUNCTION Super( x : long_Integer ) : Long_Integer ;
  22.   GEMDOS($20) ;
  23. { GEMDOS routine }
  24.  
  25. BEGIN
  26.   SSP := Super( 0 ) ; {save old supervisor stack and enter super mode}
  27.   hz_200.l := $4ba ;  {point at 200 hertz timer}
  28.   {$P-}               {turn pointer checking off}
  29.   Time := hz_200.p^ / 200 ;  {get the longword at that location and convert it}
  30.                              {to second}
  31.   {$P+}               {restore old value of pointer checking}
  32.   SSP := Super( SSP ) ; {restore supervisor stack and enter user mode}
  33. END;
  34.